﻿using System;
using System.Collections.Generic;
using System.Xml;

namespace XamlDom.Parser
{
    public class XamlNode
    {
        public XamlNode(string nodeName,string xmlNamespace)
        {
            this.NodeName = nodeName;
            this.XmlNamespace = xmlNamespace;
            this.Attributes = new List<XamlAttribute>();
        }
        
        public List<XamlNode> ChildElementNodes
        {
            get
            {
                if (LastChildNode == null)
                {
                    throw new ArgumentNullException("Last Child Node is null");
                }
                List<XamlNode> result  = new List<XamlNode>();

                for (XamlNode childNode = LastChildNode; childNode != null; childNode = childNode.PreNode)
                {
                    result.Add(childNode);
                }
                return result;
            }
        }

        public bool HasChildNode
        {
            get
            {
                return LastChildNode != null;
            }
        }

        public string NodeName { get; private set; }

        public XamlNode ParentNode { get; set; }

        public XamlNode PreNode { get; set; }

        public XamlNode NextNode { get; set; }

        public XamlNode LastChildNode { get; set; }    

        public List<XamlAttribute> Attributes { get; set; }

        public string XmlNamespace { get; set; }

        public object Instance { get; set; }
    }
}
